package work.huangxin.share.service.impl;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import work.huangxin.share.basemapper.SameService;
import work.huangxin.share.domain.schedule.ClassSecheduleVO;
import work.huangxin.share.domain.schedule.NoteInfo;
import work.huangxin.share.mapper.NoteInfoMapper;
import work.huangxin.share.service.NoteInfoService;

import java.util.List;

/**
 * @author 季台星
 * @Date 2023 04 24 13 08
 */
@Service
public class NoteInfoServiceImpl implements NoteInfoService {
    @Autowired
    private NoteInfoMapper noteInfoMapper;

    @Override
    public List<NoteInfo> getNoteInfoByUserId(Long userId) {
        return noteInfoMapper.selectNoteInfoByUserId(userId);
    }

    @Override
    public int saveNoteInfo(NoteInfo noteInfo) {
        return noteInfoMapper.insertSelective(noteInfo);
    }

    @Override
    public Long saveNoteInfoWithScheduleId(ClassSecheduleVO classSecheduleVO, Long scheduleId) {
        NoteInfo noteInfo = new NoteInfo();
        BeanUtils.copyProperties(classSecheduleVO.getNoteInfo(),noteInfo);
        noteInfo.setScheduleId(scheduleId);
        int i = noteInfoMapper.insert(noteInfo);
        System.out.println(i);
        return noteInfo.getNoteId();
    }
}
